class GetPostsByUsers {
  
  Blog _blog;
  
  GetPostsByUsers(Blog blog){
    _blog = blog;
  }

  void showWindow(){
  
    // set "BY USER" active on side bar
  	SideBar bar = _blog.getSideBar();
    bar.setActive(document.query('#filterByUser'));
  
    document.query('#GetByUsersWindow').innerHTML = Windows.getByUsersWindow();
	//setting events
	document.query('#cancelByUsers').on.click.add((events) => closeWindow());
    document.query('#getByUsers').on.click.add((events) => postToWall());
  }
  
  void closeWindow(){
  	document.query('#GetByUsersWindow').innerHTML = '';
	SideBar bar = _blog.getSideBar();
    bar.revert();
  }

  
	void postToWall(){
		var temp = document.query('#byuserfield');
		String username = temp.value;
		String url = _blog.getURL();
		document.query('#GetByUsersWindow').innerHTML = '';
		
		document.query('#pagename').innerHTML = 'Posts of $username';
		
		_blog.setPostRequester(new PostReqByUsers(_blog,url,username));
		_blog.showPosts();
	}

  
  
}// class
